<?php

/**
 * Description of SitesManager_PDO
 *
 * @author FFOZEU
 */
namespace Applications\Modules\Sites\Models;

if( !defined('IN') ) die('Hacking Attempt');

class SitesManager_PDO extends SitesManager{
    //put your code here
    
    public function getSitesInfos(){
        
        $sql = " SELECT s.* 
                 FROM ".$this->nameTable." s 
                 LIMIT 1";
        
        $requete = $this->dao->query($sql);
        
        if($data = $requete->fetch(\PDO::FETCH_ASSOC)){
            return new Sites($data);
        }
        return null;
        
        
    }
    
    public function updateSiteInfos(array $site){
        
        $sites = new Sites($site);
        
        $sql = "UPDATE ".$this->nameTable."
             SET nameSites = :nameSites, heureOuverture = :heureOuverture, heureFermeture = :heureFermeture,
             emailServClient = :emailServClient, emailServTech = :emailServTech,
             emailServReclamation = :emailServReclamation, emailPaypal = :emailPaypal, devise = :devise, isoDevise = :isoDevise";
        
        $edit = $this->dao->prepare($sql);
        
        $edit->bindValue(':nameSites',  (string)$sites->getNameSites());
        $edit->bindValue(':heureOuverture', (string)$sites->getHeureOuverture());
        $edit->bindValue(':heureFermeture', (string)$sites->getHeureFermeture());
        $edit->bindValue(':emailServClient', (string)$sites->getEmailServClient());
        $edit->bindValue(':emailServTech', (string)$sites->getEmailServTech());
        $edit->bindValue(':emailServReclamation', (string)$sites->getEmailServReclamation());
        $edit->bindValue(':emailPaypal', (string)$sites->getEmailPaypal());
        $edit->bindValue(':devise', (string)$sites->getDevise());
        $edit->bindValue(':isoDevise', (string)$sites->getIsoDevise());
        return $edit->execute();
    }
}

?>
